package com.tengju.motivation.domain.model.goods;


import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

public enum GoodsType {
    BRAND(10, "品牌"),
    SPU(20, "商品(套组)"),
    PACKAGE(30, "礼包"),
    ;

    private final int val;

    private final String desc;

    GoodsType(int val, String desc) {
        this.val = val;
        this.desc = desc;
    }

    @JsonValue
    public int getVal() {
        return val;
    }

    public String getDesc() {
        return desc;
    }

    @JsonCreator
    public static GoodsType fromVal(Integer val) {
        for (GoodsType type : values()) {
            if (type.val == val) {
                return type;
            }
        }
        return null;
    }
}
